package com.Servlet;

import com.Util.ServerDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/switch")
public class ActiveStopServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String status = req.getParameter("status");
        String username = req.getParameter("username");
        String id = req.getParameter("id");

        if(status.equals("active")){
            ServerDao.updateStatus(username, id, "stop");
        }
        else{
            ServerDao.updateStatus(username, id, "activity");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
